﻿/*******************************************************************************
 * Copyright © 2016 NFine.Framework 版权所有
 * Author: NFine
 * Description: NFine快速开发平台
 * Website：http://www.nfine.cn
*********************************************************************************/
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Reflection;
using NFine.Data.Extensions;
using System.Text;
using System.Collections;

namespace NFine.Data.Extensions
{
    public class DbHelper
    {
        private static string connstring = ConfigurationManager.ConnectionStrings["NBDbContext"].ConnectionString;
        public static int ExecSQL(string QueryText, List<DbParameter> param = null)
        {
            using (OracleConnection conn = new OracleConnection(connstring))
            {
                try
                {
                    conn.Open();
                    var dataCommond = new OracleCommand(QueryText, conn);
                    dataCommond.Parameters.Clear();
                    if (param != null)
                    {
                        foreach (var item in param)
                        {
                            dataCommond.Parameters.Add(new OracleParameter { ParameterName = item.ParameterName, Value = item.Value });
                        }
                    }
                    return dataCommond.ExecuteNonQuery();

                }
                catch (Exception ex)
                {
                    return -2;
                }
            }

        }
    }
}
